#ifndef _HTTP_H
#define _HTTP_H

#include <vector>
#include <string>
class Socket;

class Http
{
public:
  struct Response { enum Type
  {
    Ok = 200,
    PartialContent = 206,
    Found = 302,
    NotFound = 404,
  };};

  Http(Response::Type response_);
  Http(const std::string& request_);
  std::string GetRequestURL() const;
  std::string GetRequestMethod() const;
  std::string GetRequestHost() const;
  void GetRequestRange(int* range1, int* range2) const;
  void AddHeader(const std::string& header, const std::string& value);
  void SetContentHTML(const std::string& html);
  void SetContentBinary(const std::string& file);
  void SetContentBinary(const std::string& file, int range1, int range2);
  void WriteResponseToSocket(Socket& socket);

  static std::string ResponseToString(Response::Type response);
  static std::string GetMimeForFilename(const std::string& fileName);

protected:
  std::string request;
  Response::Type response;
  std::vector<std::string> headers;
  std::string htmlContent;

  std::string file;
  int range1;
  int range2;
};

#endif//_HTTP_H
